<template>
	<view class="container">
		<uv-textarea v-model="value" placeholder="请输入您的url" maxlength="-1"></uv-textarea>
		<uv-button type="primary" text="获取token" @click="getTokenBtn"></uv-button>
	</view>
</template>

<script>
import { Refresh, get_tokem } from '@/api/http/index.js';
export default {
	data() {
		return {
			value: ''
		};
	},
	methods: {
		aaa() {
			console.log(111);
		},
		getTokenBtn() {
			const regex = /skey=([^&]+)/;
			const match = this.value.match(regex);
			if (match == null) {
				
			} else {
				const skey = match ? match[1] : null;
				this.getToken(skey);
			}
		},
		//换取token
		getToken(skeyStr) {
			let data = {
				merchantNo: 'E888888886',
				appId: 'f780ea5b76544c1fa20da8048f1dd424',
				skey: skeyStr
			};
			get_tokem(data).then((res) => {
				if (res.code == 0) {
					this.$message({
						showClose: true,
						message: '登录成功，等待跳转信息页面',
						type: 'success'
					});
					vk.setVuex('$gl.token', res);
					setTimeout(() => {
						uni.navigateTo({
							url: '/pages/robInfo/robInfo'
						});
					}, 1000);
				} else {
					this.$message({
						showClose: true,
						message: res.msg,
						type: 'error'
					});
				}
			});
		}
	}
};
</script>

<style scoped lang="scss">
.container {
	display: flex;
	flex-direction: column;
}
</style>
